package dao;

import java.sql.*;

public class ConnectDatabaseDAO {
	public Connection con;
	public Statement st;

	// connect database
	public Connection connect() {
		try {
			Class.forName("org.postgresql.Driver");
			con = (Connection) DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5050/HeSinhThaiCuLaoCham", "postgres","07051990");
		} catch (ClassNotFoundException e) {
			System.out.println("Not found PostgreSQL JDBC Driver");
			e.printStackTrace();
		} catch (Exception e) {
			System.out.println("connect database failed");
		}
		System.out.println("--Connected Database--");
		return con;
	}

	// close connect
	public void closeConnect() throws SQLException {
		con.close();
		st.close();
		System.out.println("Closed connect");
	}
}
